#!/usr/bin/env python
# -*- coding: iso-8859-1 -*-
from sage.all import *
from curves import *
import metaEnhance

# from Martin Maas thesis, page 35
#http://www.ime.usp.br/~danielrb/mestrado/MT%20Martijn%20Maas.pdf

q = 11
n = 6
subfield = GF(q)
subpoli = PolynomialRing(subfield, 'x')
y = subpoli.gen()
field = GF(q ** 2, 'a', modulus = y ** 2 + 1)
a = field.gen()
Px = PolynomialRing(field, 'x')
x = Px.gen()
f = x ** 3 + 3 * x
c = Curve.createSimpleCurve(f, Px)
dd = [x - 1, Px(9)]
ee = [x - (10), Px(9 * a)]
D = c.divisorOf(dd)
E = c.divisorOf(ee)
S = n

d = (q ** embeddingDegree(q, n) - 1) / S
print "exptected = 3a + 5"
res2 = c.miller(S, d, D, E)
print "!the result is %r" % res2
res2 = c.miller(S, d, D, D)
print "!the result is %r" % res2
